package com.ckm.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Getter
@NoArgsConstructor
public class ExcelListener<T> extends AnalysisEventListener<T> {

    private final List<T> list = new ArrayList<>()    ;

    @Override
    public void invoke(T data, AnalysisContext analysisContext) {
        list.add(data);
        log.info("读取一条信息:{}",data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        log.info("{}条数据被解析",list.size());
    }
}
